package cn.com.kisen; 

import org.quartz.CronScheduleBuilder;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;

public class App {

    public static void main(String[] args) throws SchedulerException {
        // Grab the Scheduler instance from the Factory
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
        
        JobDetail job = JobBuilder.newJob(MyJob.class)
        		.withIdentity("job1", "group1").build();
        
        /*Trigger trigger = TriggerBuilder.newTrigger()
                .withIdentity("trigger1", "group1")
                .startNow()
                .withSchedule(
                		SimpleScheduleBuilder.simpleSchedule()
                        	.withIntervalInSeconds(40)
                        	.repeatForever())
                .build();*/
        Trigger trigger2 = TriggerBuilder.newTrigger()
                .withIdentity("trigger1", "group1")
                .startNow()
                .withSchedule(
                		CronScheduleBuilder.cronSchedule("0/5 * * * * ?"))
                .build();
        
        scheduler.scheduleJob(job, trigger2);
        
        // and start it off
        scheduler.start();
                

    }

}
